<template>
	<!-- 搜索页面 -->
	<view>
		<view class="search-bar">
			<u-search placeholder="请输入小区或地铁站搜索" v-model="houseTitle" :show-action="true" @search="searchHouse" @custom="searchHouse"
			 margin="20rpx" />
		</view>

		<view v-if="searchCode">
			<guessYourLike :dataList="dataList"></guessYourLike>
		</view>
		<view v-if="searchFail">
			<view style="margin-top: 20rpx;margin-left: 50rpx;">
				<!-- <u-image src="../../static/searchNull.png" style="width: 100%;height: 300rpx;"></u-image> -->
				<span>搜索内容为空</span>
			</view>
		</view>
	</view>
</template>

<script>
	import guessYourLike from '../components/palte/guessYourLike.vue'
	export default {
		data() {
			return {
				houseTitle: '',
				searchCode: false,
				searchFail: false,
				dataList: {}
			};
		},
		onLoad() {

		},
		methods: {
			async searchHouse() {
				console.log("搜取")
				//搜索房子信息
				let houseData = await this.$request({
					url: '/v1/house/list?query=' + this.houseTitle
				})
				// console.log("houseData", houseData)
				if (houseData.data.list.length !== 0) {
					this.searchFail = false
					this.searchCode = true
					let houseDataList = {
						"recommandId": 5,
						"plateName": "最新发布",
						"isShowPlateName": false,
						"houseInfo": houseData.data
					}

					this.dataList = houseDataList
					// console.log("searchData", this.dataList)
				} else {
					this.searchFail = true
					this.searchCode = false
				}
			}
		},
		components: {
			guessYourLike
		}
	}
</script>

<style>
	.search-bar {}
</style>
